/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: DuKe TeAm
 * License Type: Purchased
 */
package orm_transaccion;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;

public class TransaccionDAO {
	public static Transaccion loadTransaccionByORMID(int id_transaccion) throws PersistentException {
		try {
			PersistentSession session = orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession();
			return loadTransaccionByORMID(session, id_transaccion);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion getTransaccionByORMID(int id_transaccion) throws PersistentException {
		try {
			PersistentSession session = orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession();
			return getTransaccionByORMID(session, id_transaccion);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion loadTransaccionByORMID(int id_transaccion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession();
			return loadTransaccionByORMID(session, id_transaccion, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion getTransaccionByORMID(int id_transaccion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession();
			return getTransaccionByORMID(session, id_transaccion, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion loadTransaccionByORMID(PersistentSession session, int id_transaccion) throws PersistentException {
		try {
			return (Transaccion) session.load(orm_transaccion.Transaccion.class, new Integer(id_transaccion));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion getTransaccionByORMID(PersistentSession session, int id_transaccion) throws PersistentException {
		try {
			return (Transaccion) session.get(orm_transaccion.Transaccion.class, new Integer(id_transaccion));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion loadTransaccionByORMID(PersistentSession session, int id_transaccion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Transaccion) session.load(orm_transaccion.Transaccion.class, new Integer(id_transaccion), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion getTransaccionByORMID(PersistentSession session, int id_transaccion, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Transaccion) session.get(orm_transaccion.Transaccion.class, new Integer(id_transaccion), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion[] listTransaccionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession();
			return listTransaccionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion[] listTransaccionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession();
			return listTransaccionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion[] listTransaccionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm_transaccion.Transaccion as Transaccion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Transaccion[]) list.toArray(new Transaccion[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion[] listTransaccionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm_transaccion.Transaccion as Transaccion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Transaccion[]) list.toArray(new Transaccion[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion loadTransaccionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession();
			return loadTransaccionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion loadTransaccionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession();
			return loadTransaccionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion loadTransaccionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Transaccion[] transaccions = listTransaccionByQuery(session, condition, orderBy);
		if (transaccions != null && transaccions.length > 0)
			return transaccions[0];
		else
			return null;
	}
	
	public static Transaccion loadTransaccionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Transaccion[] transaccions = listTransaccionByQuery(session, condition, orderBy, lockMode);
		if (transaccions != null && transaccions.length > 0)
			return transaccions[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateTransaccionByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession();
			return iterateTransaccionByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTransaccionByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession();
			return iterateTransaccionByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTransaccionByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm_transaccion.Transaccion as Transaccion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateTransaccionByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm_transaccion.Transaccion as Transaccion");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion createTransaccion() {
		return new orm_transaccion.Transaccion();
	}
	
	public static boolean save(orm_transaccion.Transaccion transaccion) throws PersistentException {
		try {
			orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().saveObject(transaccion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static boolean delete(orm_transaccion.Transaccion transaccion) throws PersistentException {
		try {
			orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().deleteObject(transaccion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static boolean refresh(orm_transaccion.Transaccion transaccion) throws PersistentException {
		try {
			orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession().refresh(transaccion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static boolean evict(orm_transaccion.Transaccion transaccion) throws PersistentException {
		try {
			orm_transaccion.TransaccionesPruebaIIPersistentManager.instance().getSession().evict(transaccion);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static Transaccion loadTransaccionByCriteria(TransaccionCriteria transaccionCriteria) {
		Transaccion[] transaccions = listTransaccionByCriteria(transaccionCriteria);
		if(transaccions == null || transaccions.length == 0) {
			return null;
		}
		return transaccions[0];
	}
	
	public static Transaccion[] listTransaccionByCriteria(TransaccionCriteria transaccionCriteria) {
		return transaccionCriteria.listTransaccion();
	}
}
